<%@ page language="java" contentType="text/html; charset=BIG5"	pageEncoding="BIG5"%>

<%@page import="Cashier.Item"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">

<title>Retail System Demo</title>

<link rel="stylesheet"	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>

</head>

<body>

<div style="width:48em; height:8em; position:absolute; left:2em">

	<h1 style="font-weight: bold; margin: 1em 0em 0.5em">Retail Systems Demo</h1>

	<div class="row" style="margin: 2em 0em 2.5em -1em;">
		<form class="navbar-form navbar-left" role="search" method="get" action="Retail">	
			<div class="input-group">
				<input type="text" class="form-control" style="width:12em;" name="CODE"	placeholder="Enter Product Code"> 
 				<span class="input-group-btn">
					<button type="submit" class="btn btn-default">Input</button>
 				</span>	 							
			</div>				
		</form>
	</div>	
<%
	List<Item> items = null;
	double total = 0;
	Double payment = null;
	Double balance = null;
	Integer orderNo = null;
	String operator = null;
	
	if (!session.isNew()) {
		items = (List<Item>) session.getAttribute("items");    	
		
		if(items != null && items.size() > 0) {
			total = (Double)session.getAttribute("total");
			payment = (Double)session.getAttribute("payment");
			balance = (Double)session.getAttribute("balance");
			orderNo = (Integer)session.getAttribute("orderNo");
			operator = (String)session.getAttribute("operator");
			//System.out.println("orderNo: "+orderNo);
%>
	<div class="row" style="font-size: 2em; margin: 0em 0em 0.5em 0em;">
		<span>		
			<span class="label label-default">OrderNo:</span>	
	   		<span><%=orderNo%></span>	   		
		</span>
		
		<span style="margin: 0em 0em 0em 9.2em;">		
			<span class="label label-default">operator:</span>	
	   		<span><%=operator%></span>	   		
		</span>		
	</div>

	<table class="table table-bordered">
		<caption style="font-size: 1.6em; font-weight: bold">Selected Items Info</caption>
				
		<thead>
			<tr>
				<th>Product_ID</th>
				<th>Description</th>
				<th>Sold_Price</th>				
				<th>PurchaseQty</th>
				<th>InventoryQty</th>
				<th></th>
				<th>Subtotal</th>
			</tr>
		</thead>
		
	<tbody>		
<%
			for (int i = 0; items.size() > i; i++) {
				Item item = (Item) items.get(i);
				
%>
		<form method="get" action="Retail">			
			<tr>
				<td><%=item.getBarcode()%></td>
				<td><%=item.getDescription()%></td>
				<td><%=item.getPrice()%></td>				
				<td><input type="text" style="width:40px;" name="PurchaseQty" value=<%=item.getPurchaseQty()%>></td>
				<td><%=item.getInventoryQty()%></td>
				<input type="hidden" name="reflash" value=<%=item.getBarcode()%>>				
				<td><input type="submit" value="reflash"></td>
				<td><%=item.getSubtotal()%></td>
			</tr>		
		</form>
<%	
			} 
%>
	</tbody>
	
	</table>

		<form method="get" action="Retail">	
	<div class="row" style="font-size: 2em; margin: 2em 0em 0.5em 0em;">				
			<input type="hidden" name="clear" value="1">
			<input type="submit" value="Clear">	      
		</form>	
	
		<span style="margin: 0em 0em 0em 13em;">		
			<span class="label label-default">Total:</span>	
	   		<span>$<%=total%></span>	   		
		</span>
	</div>
	
<form method="get" action="Retail">

	<div style="position:absolute;">
  		<label class="radio-inline">
  			<input type="radio" name="paymentway" id="Radio1" value="1"> Cash
		</label>
	
		<label class="radio-inline">
  			<input type="radio" name="paymentway" id="Radio2" value="2"> CreditCard
		</label>
	
	
		<label class="radio-inline">      				
  			<input type="text" class="form-control" style="width:9em; margin: 0em 0em 0em 0em;" name="MEMBER" placeholder="Enter Member">
		</label>
  	</div>
 
  	
  	<div class="input-group" style="margin: 0em 0em 0em 32em;">  		
  		<span class="input-group-btn">
			  <button type="submit" class="btn btn-default">Payment:</button>
 		</span>	
 		<span class="input-group-addon">$</span>
 		
  		<input type="text" name="payment" value=<%= payment != null ? payment : "''"%> class="form-control" style="width:6em;">  		
	</div>

</form>

	<%
	if( balance != null )	{
	%>
	<div class="row" style="font-size: 2em; margin: 0.5em 0em 0em 0em;">				
			
		<span style="margin: 0em 0em 0em 15.5em;">		
			<span class="label label-default">Balance:</span>	
	   		<span>$<%=balance%></span>	   		
		</span>
	</div>
	
	<%
	}
	%>

<% 			
		}
	}
%>	
</div>

</body>
</html>